|
|
|
|
|
|
|
which the error applies can handle the error. For instance, handleMathErrors might look like the following: |
|
|
|
|
|
|
|
|
Private Sub handleMathErrors
If LocalErrObject.Number = DIVISION_BY_ZERO Then
'Do something about the error here
End If
End Sub |
|
|
|
|
|
|
|
|
If LocalErrObject.Number does not equal the arbitrary constant DIVISION_BY_ZERO, then the compiler essentially skips it and goes to the next method in the call stack (the list of methods in handleErrors). If none of the methods can handle it, the handleUnknownErrors method is the catch-all, alerting the client to an unknown error. |
|
|
|
|
|
|
|
|
Practical Guidelines for Implementing the Error-Processing and Exception-Handling Subsystem |
|
|
|
|
|
|
|
|
To reiterate, be sure that all significant methods and global functions make calls to the ErrorHandler object for complete error handling. Having a centralized object handle as many errors as is possible makes maintaining the code behind your applications easier. Plus, there's less chance of duplicating error-handling code unnecessarily. |
|
|
|
|
|
|
|
|
Incorporating the Subsystem into the Samsona Bank Teller System Example |
|
|
|
|
|
|
|
|
For the Second Bank of Carrollton, you decided you need to place calls to ErrorHandler in all of the methods that are involved in banking transactions. Listing 18.6 shows the deposit method of the DepositFunds class. In the exercises at the end of this lesson, you will implement the method calls for the other banking methods. |
|
|
|
|
|
|
|
|
LISTING 18.6. ERROR HANDLING ORIGINATING IN THE DEPOSIT METHOD OF THEDepositFundsCLASS. |
|
|
|
 |
|
|
|
|
1:
2: Public Sub Deposit()
3: On Error GoTo depositErr
4: 'your code goes here. . .
5: If theSomeWorkgroupProxy.CurrProcess.isCurrTaskComplete Then
6: theApplication.theAppTransactions.addTrans2MemLog Deposited funds
|
|
|
|
|
|